<template>
  <div class="dialog">
    <el-dialog title="我的申请" :visible.sync="dialog.show" :close-on-click-modal="false" :close-on-press-escape="false"
      :modal-append-to-body="false">

      <div class="form">
        <el-form ref="form" :model="formData" :rules="form_rules" label-width="120px" style="margin:10px;width:auto">
          <!-- 姓名 -->
          <el-form-item label="请输入姓名">
            <el-input type="text" v-model="formData.name"></el-input>
          </el-form-item>
          <!-- 性别 -->
          <el-form-item label="性别：">
            <el-select v-model="formData.sex" placeholder="请选择性别">
              <el-option v-for="(s, index) in sexs" :key="index" :value="s"></el-option>
            </el-select>
          </el-form-item>
          <!-- 年龄 -->
          <el-form-item label="请输入年龄">
            <el-input type="text" v-model="formData.age"></el-input>
          </el-form-item>
          <!-- 学历 -->
          <el-form-item label="学历：">
            <el-select v-model="formData.study" placeholder="请选择学历">
              <el-option v-for="(d, index) in study" :key="index" :value="d"></el-option>
            </el-select>
          </el-form-item>
          <!-- 工作经验 -->
          <el-form-item label="工作经验：">
            <el-input type="textarea" v-model="formData.expreance"></el-input>
          </el-form-item>
          <!-- 自我评价 -->
          <el-form-item label="自我评价：">
            <el-input type="textarea" v-model="formData.comment"></el-input>
          </el-form-item>

          <el-form-item class="test_right">
            <el-button @click="dialog.show = false">取消</el-button>
            <el-button type="primary" @click="onSubmit">提交</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
  </div>
</template>

<script>

export default {
  name: 'Dialog',
  data() {
    return {
      formData: {
        name: '',
        sex: '',
        age: '',
        expreance: '',
        comment: ''
      },
      sexs: [
        "男",
        "女",
      ],
      study: [
        "高中",
        "大专",
        "本科",
        "研究生",
        "博士",
      ],
      form_rules: {
        // description: {
        //   required: true, message: "收支描述不能为空", trigger: "blur"
        // },
        // income: {
        //   required: true, message: "收入不能为空", trigger: "blur"
        // },
        // expenditure: {
        //   required: true, message: "支出不能为空", trigger: "blur"
        // },
        // account: {
        //   required: true, message: "账户不能为空", trigger: "blur"
        // },
      },
      status: '等待审阅...'
    }
  },
  props: {
    dialog: Object,
    //接收父组件传过来的job
    ad: [],
    tg: [],
  },
  methods: {
    onSubmit() {
      // console.log(this.formData.name)
      // console.log(this.ad)
      // console.log(this.tg)
      this.$axios.post('/api/user_application/addApplication',
        { name: this.formData.name, sex: this.formData.sex, age: this.formData.age, graduation: this.formData.study, expreance: this.formData.expreance, comment: this.formData.comment, application_garden: this.tg, application_job: this.ad, status: this.status })
        .then(res => {
          alert('申请成功，等待审阅.....')
        })
    }
  }
}
</script>
<style scoped></style>